package sy.s6_6;


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        double x1 = input.nextDouble();
        double y1 = input.nextDouble();
        double x2 = input.nextDouble();
        double y2 = input.nextDouble();
        MyPoint p1 = new MyPoint(x1,y1);
        MyPoint p2 = new MyPoint(x2,y2);
        MyPoint p3;
        MyPoint p4;
        System.out.printf("distance between Point(%.2f,%.2f) and Point(%.2f,%.2f) is %.2f\n",
                p1.getX(), p1.getY(), p2.getX(), p2.getY(), p1.distance(p2));
        double dx1 = input.nextDouble();
        double dy1 = input.nextDouble();
        double dx2 = input.nextDouble();
        double dy2 = input.nextDouble();
        p3 = p1.move(dx1,dy1);
        p4 = p2.move(dx2,dy2);
        System.out.printf("distance between Point(%.2f,%.2f) and Point(%.2f,%.2f) is %.2f\n",
                p1.getX(), p1.getY(), p2.getX(), p2.getY(), p1.distance(p2));
        System.out.printf("distance between Point(%.2f,%.2f) and Point(%.2f,%.2f) is %.2f\n",
                p3.getX(), p3.getY(), p4.getX(), p4.getY(), p3.distance(p4));
    }
}

/* 请在这里填写答案 */
class MyPoint {
//    私有成员变量x和y代表坐标，类型为double。
    private double x;
    private double y;

//    一个不带参数的构造方法MyPoint()，x和y都设为0.0。
    MyPoint() {
        x = 0.0;
        y = 0.0;
    }
//    一个有参构造方法MyPoint(double x,double y),构造一个指定的坐标点，如果x和y小于0，则设为0。
    MyPoint(double x, double y) {
        if (x < 0) {
            this.x = 0.0;
        } else {
            this.x = x;
        }
        if (y < 0) {
            this.y = 0.0;
        } else {
            this.y = y;
        }
    }
//    为x和y添加getter方法，都为公共方法。
    public double getX() {
        return x;
    }
    public double getY() {
        return y;
    }
//    public MyPoint move(double dx, double dy)方法, 生成并返回一个横坐标移动dx，纵坐标移动dy后的新的MyPoint对象（如果移动后坐标小于0，则设为0）。
    public MyPoint move(double dx, double dy) {
        double newX = x + dx;
        double newY = y + dy;
        return new MyPoint(newX, newY);
    }
//    public double distance(MyPoint p)方法, 返回该点到指定点p的距离。
    public double distance(MyPoint p) {
        return Math.sqrt(Math.pow(this.x - p.x, 2) + Math.pow(this.y - p.y, 2));
    }
}